package demo;

import java.util.concurrent.Semaphore;

public class demo7 {
    public static void main(String[] args) throws InterruptedException {
        Semaphore semaphore=new Semaphore(3);

        semaphore.acquire();
        System.out.println("申请资源");

        semaphore.acquire();
        System.out.println("申请资源");

        semaphore.acquire();
        System.out.println("申请资源");

        semaphore.release();
        System.out.println("释放资源");

        semaphore.acquire();
        System.out.println("申请资源");
    }
}
